package com.jiamao.goplay.ui.user.vm;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.jiamao.goplay.AViewModel;
import com.jiamao.goplay.bean.BaseRep;
import com.jiamao.goplay.bean.PlaceWantGoItem;
import com.jiamao.goplay.ui.discover.AddrDetailFragment;
import com.jiamao.goplay.ui.discover.SearchFragment;
import com.jiamao.goplay.ui.user.UserAddrDetailFragment;
//import com.tamsiree.rxkit.view.RxToast;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.observers.DisposableObserver;
import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.MultiItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.utils.RxUtils;

public class UserWantGotoItemVM extends MultiItemViewModel {

    public ObservableField<String> title = new ObservableField<>("");
    public ObservableField<String> nums = new ObservableField<>("0人邀请我");
    public ObservableField<String> imgUrl = new ObservableField<>("");
    public ObservableField<ArrayList<String>> list = new ObservableField<ArrayList<String>>();

    private String id;
    private UserWantGotoVM gotoVM;
    public UserWantGotoItemVM(@NonNull BaseViewModel viewModel,PlaceWantGoItem item) {
        super(viewModel);
        if (viewModel instanceof UserWantGotoVM ){
            this.gotoVM = (UserWantGotoVM) viewModel;
        }

        if (item == null){
            return;
        }
        id = item.getPlaceId();
        imgUrl.set(item.getPlaceCover());
        nums.set(item.getInviteUser()+"人邀请我");
        title.set(item.getPlaceName());
        list.set(item.getInviteUserAvatar());

    }

    //条目的点击事件
    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            Bundle bd = new Bundle();
            bd.putString("id",id);
           viewModel.startContainerActivity(UserAddrDetailFragment.class.getCanonicalName(),bd);
        }
    });

    //条目的点击事件
    public BindingCommand delClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {

            gotoVM.removeCloection(id,UserWantGotoItemVM.this);
           // viewModel.startContainerActivity(AddrDetailFragment.class.getCanonicalName(),bd);
        }
    });







}
